extends layout-customer

block head

block content
	h1.page-header= title
	
	h2.sub-header Einkaufsartikel
	
	form(method='post', action='/shopping_item/update')
		input(type='hidden', name='_csrf', value=_csrf)
		input(type='hidden', name='id', value=item.id)
		table.table.table-striped
			tr
				td Name
				td
					input.form-control(type='text', name='name', value=item.name)
			tr
				td Besitzer
				td
					script(type="application/javascript")
						|function changeOwnerButton(value,name){
						|	console.log("v:"+value+" n:"+name);
						|	document.getElementById('select-owner').value = value;
						|	document.getElementById('owner-button-text').textContent = name+" ";
						|};	
					input#select-owner(type='hidden', name='owner')
					div.input-group
						div.input-group-btn
							button.btn.btn-default.dropdown-toggle#owner-button(type='button', data-toggle='dropdown', size='1')
								span#owner-button-text -- Wähle Besitzer --
								span.caret
							ul.dropdown-menu(role='menu')
								each member in members
									li
										a(onclick='changeOwnerButton('+member.id+',"'+member.name+'")' value=member.id)= member.name
									if member.id === item.owner
										script(type="application/javascript")
											|changeOwnerButton(
											= member.id
											|,"
											= member.name
											|");
			tr
				td Preis
				td
					div.input-group
						input.form-control(type='text', name='price', value=item.price/100)
						span.input-group-addon €
		input.btn.btn-primary(type='submit', value='Ändern')
		
	form(method='post', action='/shopping_item/delete')
		input(type='hidden', name='_csrf', value=_csrf)
		input(type='hidden', name='id', value=item.id)
		input.btn.btn-danger(type='submit', value='Löschen')
